<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <el-button @click="handleClick">111</el-button>
    <el-button @click="handleClick2">发请求</el-button>

  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  methods: {
    handleClick () {
      chrome.runtime.sendMessage({ message: 'hello' }, (response) => {
        console.log('收到响应：' + response.message)
      })
    },
    handleClick2 () {
      // 导入Axios
      // 发送GET请求
      axios.get('https://api.example.com/data')
        .then(function (response) {
          // 请求成功时处理响应
          console.log(response.data)
        })
        .catch(function (error) {
          // 请求失败时处理错误
          console.error(error)
        })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
.hello {
  width: 200px;
}
</style>
